package cn.jhz.learn.blog.controller.security;

import cn.jhz.learn.blog.common.bean.JsonData;
import cn.jhz.learn.blog.common.exception.ParamException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CoreExceptionHandler {

    @ResponseStatus(HttpStatus.PRECONDITION_FAILED)
    @ExceptionHandler(ParamException.class)
    public JsonData paramError(Exception e){
        return JsonData.fail(e.getMessage());
    }
}
